 #include "stm32f4xx.h"
#include "math1.h"   
#include "math.h"   
  double data[91]={0,0.01745241,0.0348995,0.05233596,0.06975647,
0.08715574,0.1045285,0.1218693,0.1391731,0.1564345,
0.1736482,0.190809,0.2079117,0.2249511,0.2419219,
0.258819,0.2756374,0.2923717,0.309017,0.3255682,
0.3420202,0.3583679,0.3746066,0.3907311,0.4067366,
0.4226183,0.4383712,0.4539905,0.4694716,0.4848096,
0.5,0.5150381,0.5299193,0.5446391,0.5591929,
0.5735765,0.5877852,0.601815,0.6156615,0.6293204,
0.6427876,0.656059,0.6691306,0.6819984,0.6946584,
0.7071068,0.7193398,0.7313537,0.7431448,0.7547096,
0.7660444,0.777146,0.7880108,0.7986355,0.809017,
0.8191521,0.8290375,0.8386706,0.8480481,0.8571673,
0.8660254,0.8746197,0.8829476,0.8910065,0.8987941,
0.9063078,0.9135454,0.9205049,0.9271839,0.9335804,
0.9396926,0.9455186,0.9510565,0.9563047,0.9612617,
0.9659258,0.9702957,0.9743701,0.9781476,0.9816272,
0.9848077,0.9876884,0.9902681,0.9925461,0.9945219,
0.9961947,0.9975641,0.9986295,0.9993908,0.9998477,
1};
	
static  uint8_t arcSin(float f){
	if(f>=1){
		return 90;
	}
	uint8_t b=0;
	uint8_t e=90;
	while(e-b>1){
		uint8_t m= (b+e)>1;
		if(data[m]>f){
			e=m;
		}else if(data[m]<f){
			b=m;
		}else{
			return m;
		}
	}
	if(f-data[b]>data[e]-f){
		return e;
	}else{
		return b;
	}
	
}
	//[-90 90]
int aSin(float f){
	if(f>=0){
		return arcSin( f);
	}else{
		return -arcSin( -f);
	}
}
//[0,180]
int aCos(float f){
     float fd= atan2(0,3);
	if(f>=0){
		return 90-arcSin( f);
	}else{
		return 90+arcSin( -f);
	}
  
}

